package com.jm.jisho.ocr;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;	
import android.util.AttributeSet;

class ImageViewTouch extends ImageViewTouchBase
{
  int StrokeWidth = 5;
  Paint mPaint = new Paint();
  boolean mShowBox = false;
  RectF mTextBox = new RectF();
  RectF mTextBoxScreen = new RectF();

  public ImageViewTouch(Context paramContext)
  {
    super(paramContext);
  }

  public ImageViewTouch(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.mPaint.setColor(-65536);
    this.mPaint.setStyle(Style.STROKE);
    this.mPaint.setStrokeWidth(3.0F);
  }

  public void dismissBox()
  {
    this.mShowBox = false;
    invalidate((int)this.mTextBox.left, (int)this.mTextBox.top, (int)this.mTextBox.right, (int)this.mTextBox.bottom);
  }

  public void drawBox(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
  {
    this.mShowBox = false;
    invalidate((int)this.mTextBoxScreen.left - this.StrokeWidth, (int)this.mTextBoxScreen.top - this.StrokeWidth, (int)this.mTextBoxScreen.right + this.StrokeWidth, (int)this.mTextBoxScreen.bottom + this.StrokeWidth);
    Matrix localMatrix = getImageMatrix();
    this.mTextBox.set(paramFloat1 - 1.0F, paramFloat2 - 2.0F, 2.0F + paramFloat1 + paramFloat3, 4.0F + paramFloat2 + paramFloat4);
    this.mTextBoxScreen.set(paramFloat1 - 1.0F, paramFloat2 - 2.0F, 2.0F + paramFloat1 + paramFloat3, 4.0F + paramFloat2 + paramFloat4);
    localMatrix.mapRect(this.mTextBoxScreen, this.mTextBox);
    this.mShowBox = true;
    invalidate((int)this.mTextBoxScreen.left - this.StrokeWidth, (int)this.mTextBoxScreen.top - this.StrokeWidth, (int)this.mTextBoxScreen.right + this.StrokeWidth, (int)this.mTextBoxScreen.bottom + this.StrokeWidth);
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
    if (this.mShowBox)
    {
      getImageMatrix().mapRect(this.mTextBoxScreen, this.mTextBox);
      paramCanvas.drawRect(this.mTextBoxScreen, this.mPaint);
    }
  }

  protected void postTranslateCenter(float paramFloat1, float paramFloat2)
  {
    super.postTranslate(paramFloat1, paramFloat2);
    center(true, true);
  }
}